package com.macro.mall.model;

import cn.hutool.json.JSONObject;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * cur_course_stat实体类
 *
 * @author gaodx
 *
 */
@Data
@Builder
@AllArgsConstructor
public class CurCourseStat implements Serializable{
	/**主键*/
    @ApiModelProperty(value = "主键")
	private Long id; 
	/**课程标识*/
    @ApiModelProperty(value = "课程标识")
	private Long courseId; 
	/**播放次数*/
    @ApiModelProperty(value = "播放次数")
	private Long playCount; 
	/**综合评星*/
    @ApiModelProperty(value = "综合评星")
	private Double star; 
	/**分享次数*/
    @ApiModelProperty(value = "分享次数")
	private Long shareCount; 
	/**收藏数量*/
    @ApiModelProperty(value = "收藏数量")
	private Long collectCount; 
	/**
	 * 实例化
	 */
	public CurCourseStat() {
		super();
	}
	/**
	 * 实例化
	 * 
	 * @param obj
	 */

	public CurCourseStat(JSONObject obj) {
		this();
		if (obj.get("id") instanceof Number) {
			this.setId(((Number) obj.get("id")).longValue());
		}
		if (obj.get("courseId") instanceof Number) {
			this.setCourseId(((Number) obj.get("courseId")).longValue());
		}
		if (obj.get("playCount") instanceof Number) {
			this.setPlayCount(((Number) obj.get("playCount")).longValue());
		}
		if (obj.get("star") instanceof Number) {
			this.setStar(((Number) obj.get("star")).doubleValue());
		}
		if (obj.get("shareCount") instanceof Number) {
			this.setShareCount(((Number) obj.get("shareCount")).longValue());
		}
		if (obj.get("collectCount") instanceof Number) {
			this.setCollectCount(((Number) obj.get("collectCount")).longValue());
		}
	}
	
	/**
	 * 将当前对象转换为JsonObject
	 * 
	 * @return
	 */
	public JSONObject toJson() {
		JSONObject result = new JSONObject();
		if (this.getId() != null) {
			result.put("id",this.getId());
		}
		if (this.getCourseId() != null) {
			result.put("courseId",this.getCourseId());
		}
		if (this.getPlayCount() != null) {
			result.put("playCount",this.getPlayCount());
		}
		if (this.getStar() != null) {
			result.put("star",this.getStar());
		}
		if (this.getShareCount() != null) {
			result.put("shareCount",this.getShareCount());
		}
		if (this.getCollectCount() != null) {
			result.put("collectCount",this.getCollectCount());
		}
		return result;
	}


	@Override
	public String toString() {
		return "CurCourseStat [id=" + id + " , courseId=" + courseId + " , playCount=" + playCount + " , star=" + star + " , shareCount=" + shareCount + " , collectCount=" + collectCount + "  ]";
	
	}
	
	
}
